package com.crm.dataReceive.domain;

import lombok.extern.slf4j.Slf4j;

import java.util.HashMap;
import java.util.Map;

/**
 * 功能说明: API公共逻辑定义<br>
 * 开发人员: @author Mr.Wen<br>
 * 开发时间: 2021-11-15 22:44<br>
 **/
@Slf4j
public class BaseApi {
    public static String ERRORNO_KEY = "errorNo";
    public static String ERRORINFO_KEY = "errorInfo";
    public static String ERROR_NO_KEY = "error_no";
    public static String ERROR_INFO_KEY = "error_info";
    public static String CODE = "code";
    public static String ERR_CODE = "errCode";
    public static String BUSINESSCODE = "businessCode";
    public static String MESSAGE = "message";
    public static String MSG = "msg";

    public static String DATA = "data";
    public static String STATUS = "status";
    public static String REGEX_CHINESE = "[\u4e00-\u9fa5]";// 中文正则
    public static String REGEX_SPLIT = "-"; // 数据分隔符
    public static String REGEX_CITY = "市";

    /**
     * 返回结果组装
     *
     * @param code
     * @param businessCode
     * @param msg
     * @return
     */
    public Map<String, Object> buildResp(String code, String businessCode, String msg) {
        Map<String, Object> resMap = new HashMap<>(3);
        resMap.put(CODE, code);
        resMap.put(BUSINESSCODE, businessCode);
        resMap.put(MSG, msg);
        return resMap;
    }


    /**
     * 返回结果组装V2
     *
     * @param code
     * @param msg
     * @return
     */
    public Map<String, Object> buildRespV2(int code, String msg, String[] data) {
        Map<String, Object> resMap = new HashMap<>(3);
        resMap.put(CODE, code);
        resMap.put(MSG, msg);
        resMap.put(DATA, data);
        return resMap;
    }

    /**
     * 返回结果组装V3
     *
     * @param code
     * @param msg
     * @return
     */
    public Map<String, Object> buildRespV3(int code, String msg, int status) {
        Map<String, Object> resMap = new HashMap<>(3);
        resMap.put(CODE, code);
        resMap.put(MSG, msg);
        Map<String, Object> data = new HashMap<>();
        data.put(STATUS, status);
        resMap.put(DATA, data);
        return resMap;
    }

    /**
     * 返回结果组装V4
     *
     * @param code
     * @param msg
     * @return
     */
    public Map<String, Object> buildRespV4(int code, String msg, Boolean status) {
        Map<String, Object> resMap = new HashMap<>(3);
        resMap.put(CODE, code);
        resMap.put(MSG, msg);
        resMap.put(STATUS, status);
        return resMap;
    }
    /**
     * 返回结果组装V5
     *MESSAGE 不一样
     * @param code
     * @param msg
     * @return
     */
    public Map<String, Object> buildRespV5(int code, String msg, String[] data) {
        Map<String, Object> resMap = new HashMap<>(3);
        resMap.put(CODE, code);
        resMap.put(MESSAGE, msg);
        resMap.put(DATA, data);
        return resMap;
    }
}
